package com.sailing.lianxi.design.prototype;

import java.util.HashMap;

import jdk.nashorn.internal.runtime.regexp.joni.Regex;

/**
 * 创建一个类，从数据库获取实体类，并把它们存储在一个 Hashtable 中。
 * @author Administrator
 *
 */
public class ShapeCache {

	private static HashMap<String, Shape> shapeMap = new HashMap<String, Shape>();
	
	public static Shape getShape(String shapeId){
		Shape cacheShape = shapeMap.get(shapeId);
		return (Shape) cacheShape.clone();
	}
	
	public static void loadCache(){
		
		Circle circle = new Circle();
		circle.setId("1");
		shapeMap.put(circle.getId(), circle);
		
		Rectangle rectangle = new Rectangle();
		rectangle.setId("2");
		shapeMap.put(rectangle.getId(), rectangle);
	}
}
